package result

import (
	"github.com/kataras/iris/v12"
)

const min InnerCode = 1000
const (
	//
	Code_Username_Error InnerCode = iota + min
	Code_Password_Error
	Code_Token_Invalid
	Code_Token_Expired
	Code_Token_Empty
	Code_User_Disabled
	Code_User_IsRoot
	//
	Code_Record_NotFound
	Code_DataDuplicate
	//
	Code_QRCode_Duplicate
	Code_Excel_FormatError
	// wms
	Wms_Code_Bill_Not_Goods
	Wms_Bill_Ountbound_Not_Qty
	Wms_Bill_Pandian_Qty_Noteq
	Wms_Bill_Pandian_Overed
	Wms_Bill_Pandian_Qty_Not_Changed
)
const unknownMsg = "抱歉，未知的状态码。请联系[运维系统]的人员"

// 内部消息码
type InnerCode int

func (code InnerCode) message() string {
	var msg string = unknownMsg
	switch code {
	case iris.StatusOK:
		return "操作成功"
	case iris.StatusBadRequest:
		msg = "抱歉，请求参数有误"
	case iris.StatusUnauthorized:
		msg = "抱歉，您的会话已过期！请重新登陆"
	case iris.StatusForbidden:
		msg = "抱歉，您没有相应的权限"
	case iris.StatusNotFound:
		msg = "抱歉，您请求的资源不存在"
	case iris.StatusInternalServerError:
		msg = "抱歉，操作失败。服务器内部异常"
		//
	case Code_Username_Error:
		msg = "抱歉，账号有误。请检查！"
	case Code_Password_Error:
		msg = "抱歉，密码错误。请检查！"
	case Code_Token_Invalid:
		msg = "抱歉，无效令牌"
	case Code_Token_Expired:
		msg = "抱歉，您的令牌已过期。请重新登陆"
	case Code_Token_Empty:
		msg = "抱歉，令牌不能为空"
	case Code_User_Disabled:
		msg = "抱歉，该账号已被禁用/冻结"
	case Code_User_IsRoot:
		msg = "抱歉，不能删除超级用户"
	//
	case Code_Record_NotFound:
		msg = "抱歉，查询的数据不存在"
	case Code_DataDuplicate:
		msg = "抱歉，您提交了重复数据，请检查！"
	//
	case Code_QRCode_Duplicate:
		msg = "抱歉，二维码已重复"
	case Code_Excel_FormatError:
		msg = "抱歉，excel格式错误，请检查"
	//
	case Wms_Code_Bill_Not_Goods:
		msg = "抱歉，单据不能没有货物。请添加货物！"
	case Wms_Bill_Ountbound_Not_Qty:
		msg = "抱歉，该仓库货物不足！"
	case Wms_Bill_Pandian_Qty_Noteq:
		msg = "抱歉，计划数量不等于现有仓库数量，请锁住系统，并创建新盘点！"
	case Wms_Bill_Pandian_Overed:
		msg = "抱歉，该盘点已结束！"
	case Wms_Bill_Pandian_Qty_Not_Changed:
		msg = "盘点的货物数量没有变化！"
	}
	return msg
}
